package com.ruoyi.web.controller.main;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.InsuredPersons;
import com.ruoyi.system.service.IInsuredPersonsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 参保人员信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-13
 */
@Api("参保人员信息")
@RestController
@RequestMapping("/system/insuredPersons")
public class InsuredPersonsController extends BaseController
{
    @Autowired
    private IInsuredPersonsService insuredPersonsService;

    /**
     * 查询参保人员信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:persons:list')")
    @GetMapping("/list")
    @ApiOperation("查询参保人员信息列表")
    public TableDataInfo list(InsuredPersons insuredPersons)
    {
        startPage();
        List<InsuredPersons> list = insuredPersonsService.selectInsuredPersonsList(insuredPersons);
        return getDataTable(list);
    }


    /**
     * 获取参保人员信息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:persons:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取参保人员信息详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(insuredPersonsService.selectInsuredPersonsById(id));
    }

    /**
     * 新增参保人员信息
     */
//    @PreAuthorize("@ss.hasPermi('system:persons:add')")
    @Log(title = "参保人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增参保人员信息")
    public AjaxResult add(@RequestBody InsuredPersons insuredPersons)
    {
        return toAjax(insuredPersonsService.insertInsuredPersons(insuredPersons));
    }

    /**
     * 修改参保人员信息
     */
//    @PreAuthorize("@ss.hasPermi('system:persons:edit')")
    @Log(title = "参保人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改参保人员信息")
    public AjaxResult edit(@RequestBody InsuredPersons insuredPersons)
    {
        return toAjax(insuredPersonsService.updateInsuredPersons(insuredPersons));
    }

    /**
     * 删除参保人员信息
     */
//    @PreAuthorize("@ss.hasPermi('system:persons:remove')")
    @Log(title = "参保人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除参保人员信息")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(insuredPersonsService.deleteInsuredPersonsByIds(ids));
    }
}
